package mine.gui.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import mine.core.AlgoCal;
import mine.gui.ControlWindow;
import mine.imgproc.Img2Cells;
import mine.imgproc.Img2CellsImpl;
import mine.mouse.MouseActions;
import mine.mouse.RobotMouse;
import mine.mouse.ScreenActions;

public class EventCaller implements ActionListener {

	private MouseActions mouse;
	private ScreenActions screen;
	private Img2Cells imgCell= new Img2CellsImpl();
	private AlgoCal core;
	public EventCaller () {
		RobotMouse robot = new RobotMouse();
		this.mouse = robot;
		this.screen = robot;
		this.core = new AlgoCal(mouse, screen, imgCell);
	}
	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		if(arg0.getActionCommand().equals(ControlWindow.RUN)) {
//			mouse.clickLeftRight(500, 500);
			//TODO : use imgCell to return the cells, call algoCal mark and click.
			core.autoBegin();
			//for test below
			
			Img2CellsImpl test = new Img2CellsImpl();
			test.updateCurrentImage(screen.getCurrentScreen());
			mouse.clickLeft(1008, 740);
			test.forTest(1008,740);
		}
		if(arg0.getActionCommand().equals(ControlWindow.EXIT)) {
			System.exit(0);
		}
	}

}
